#include "LcdControl.h"
#include "UIMessage.h"
#include "dlg.h"
#include "calllogWinDlg.h"
#include "call_log.h"
#include "GUI_LCD.h"

typedef struct WG_CalogDialState{
  Widget Widget;
  uint8_t IsMiss;
  uint8_t Dir;
}WG_CalogDialState;

WG_CalogDialState _calog_dialstate = {0};
Widget *calogDialState;

static void callogDialStateCallback(WM_Message* pMsg)
{
  switch(pMsg->msgType)
  {
    case WM_KEY:
      break;
    case WM_CREATE:
      break;
    case WM_FOCUS:
      break;
    case WM_PAINT:
      if(_calog_dialstate.Widget.States >= WG_VISIBLE && pMsg->data_v)
      {
        if(_calog_dialstate.IsMiss == CALL_MISS)
          GUI_LCDSetS(LCD_S33, 1);
        else
          GUI_LCDSetS(LCD_S33, 0);
        if(_calog_dialstate.Dir == CALL_DIR_IN)
        {
          GUI_LCDSetS(LCD_S34, 1);
          GUI_LCDSetS(LCD_S35, 0);
        }
        else if(_calog_dialstate.Dir == CALL_DIR_OUT)
        {
          GUI_LCDSetS(LCD_S35, 1);
          GUI_LCDSetS(LCD_S34, 0);
        }
      }
      else
      {
        GUI_LCDSetS(LCD_S33, 0);
        GUI_LCDSetS(LCD_S34, 0);
        GUI_LCDSetS(LCD_S35, 0);
      }
      break;
    
  }
  return;
}

Widget* calogDialStateCreate(void)
{
  WG_Create((Widget*)&_calog_dialstate, &calogWin, callogDialStateCallback);
  calogDialState = (Widget*)&_calog_dialstate;
  return calogDialState;
}

void calogDialStateSet(uint8_t IsMiss, uint8_t Dir)
{
  _calog_dialstate.Dir = Dir;
  _calog_dialstate.IsMiss = IsMiss;
}

